const express=require("express")
const router=express.Router()
const bokeServ=require("../../services/lyservice")

const {
    asyncHandler
}=require("../getSendResult")

router.get("/",asyncHandler(async(req,res,next)=>{
    const page=req.query.page||1;
    const limit=req.query.limit||5;
    return await bokeServ.getfindall(page,limit);
}))
router.post("/add",asyncHandler(async(req,res,next)=>{
    if(req.body.text){
        const text=req.body.text
        const name=req.body.name
        const img=req.body.img
        const data=req.body.$today
        return await bokeServ.add({text,data,img,name})
    }else{
         throw new Error("Text is not null !!!")
    }
}))
module.exports = router